<template>
  <el-card style="height: 99%;padding: 0px">
    <p style="margin-left: 10px">首页>订单管理</p>
    <el-table
        :data="tableData"
        border
        style="width: 100%;line-height: 50px;margin-top: 10px;margin-bottom: 10px">
      <el-table-column type="expand"  style="width: 80%;line-height: 20px;margin-left: 10px;margin-bottom: 10px">
        <template slot-scope="props">
          <el-table :show-header="false" :data="props.row.orderChildrens">
            <el-table-column
                label="菜单名称"
                prop="name">
            </el-table-column>
            <el-table-column
                label="菜单单价"
                prop="price">
            </el-table-column>
            <el-table-column
                label="数量"
                prop="num">
            </el-table-column>
            <el-table-column
                label="总价"
                prop="total">
            </el-table-column>
          </el-table>
        </template>
      </el-table-column>
      <el-table-column
          prop="id"
          label="订单编号">
      </el-table-column>
      <el-table-column
          prop="price"
          label="订单总价">
      </el-table-column>
      <el-table-column
          prop="student.name"
          label="学生姓名">
      </el-table-column>
      <el-table-column
          prop="phone"
          label="联系方式">
      </el-table-column>
      <el-table-column
          prop="isPay"
          label="订单状态">
        <template slot-scope="scope">
          <el-tag type="success" v-if="scope.row.isPay == true">已支付</el-tag>
          <el-tag type="danger" v-if="scope.row.isPay == false">未支付</el-tag>
        </template>
      </el-table-column>
      <el-table-column
          prop="creatTime"
          label="订单时间">
      </el-table-column>
    </el-table>
    <el-pagination
        background
        layout="prev, pager, next"
        :total="pageInfo.total"
        :page-size="pageInfo.pageSize"
        @current-change="handleCurrentChange">
    </el-pagination>
  </el-card>
</template>

<script>
import {doGetOrders} from "@/api/order";

export default {
  name: "orderInfo",
  data() {
    return {
      tableData:[
      ],
      pageInfo:{
        total:1,
        pageNum:1,
        pageSize:3
      }
    }
  },methods: {
      getStudent(){
          doGetOrders(this.pageInfo.pageNum,this.pageInfo.pageSize).then(res=>{
              if (res.code===200){
                  this.pageInfo.total=res.data.total;
                  this.tableData=res.data.records;
              }
          })
      },
    handleCurrentChange(val) {
      this.pageInfo.pageNum=val;
      this.getStudent();
    }
  },
  mounted() {
    this.getStudent();
  }
}
</script>

<style lang="less" scoped>

</style>